package com.sh.ndt.login.service;

import com.sh.ndt.login.dao.LoginDAO;
import com.sh.ndt.user.entity.User;
import com.sh.ndt.user.entity.UserRole;
import java.io.Serializable;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Class implementing LoginServiceImpl interface
 *
 * @author Prashanth
 */
public class LoginServiceImpl implements LoginService, Serializable {

    private static final long serialVersionUID = 1L;
    private static Logger logger = Logger.getLogger(LoginServiceImpl.class);
    LoginDAO loginDao;
    private User userEntity;

    public LoginServiceImpl() {
        logger.debug("************************** Login Service: Initialized");
    }

    public LoginServiceImpl(LoginDAO loginDao) {
        //System.out.println("Login Service: got Login DAO obj through Spring");
        //System.out.println(loginDao.toString());
        logger.debug("************************** Login Service: Initialized");
        this.loginDao = loginDao;
    }

    
    @Override
    public boolean authenticateUser(String userName) {

        boolean result;

        //ILoginDAO loginDAOObject = new LoginDAO();
        result = loginDao.authenticateUser(userName);
        if (result) {

            logger.debug("In user bean: userId = " + loginDao.getUserData().getUserId()+ "  Now calling entitlement service to get data...");
            //extractEntitlementData(loginDao.getUserData().getIdtUser());
            
//            this.getSessionProperties().setUserEntity(loginDao.getUserData());
//            this.getSessionProperties().setCompensationService(compensationService);
//            this.getSessionProperties().setUserEntitlementService(userEntitlementService);
        }
        return result;
    }

    @Override
    public User getUserData() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public UserRole getUserRoleData() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public User getUserEntity() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }


}
